package card;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class cardGame {
    public static final String[] pic = {"♥","♣","♠","♦"};
    public List<Card> buyCard(){
        List<Card> cardList = new ArrayList<>();
        for (int i = 0; i < 4; i++) {
            for (int j = 1; j < 14; j++) {
                Card card = new Card(pic[i],j);
                cardList.add(card);
            }
        }
        return cardList;
    }

    /*
    * 使用交换的方式洗牌
    */
    public void shuffle(List<Card> cardList){
        Random random = new Random();
        for (int i = cardList.size()-1; i > 0; i--) {
            int index = random.nextInt(i);
            swap(cardList,i,index);
        }
    }

    private static void swap(List<Card> cardList,int i,int index){
        Card tmp = cardList.get(i);
        cardList.set(i,cardList.get(index));
        cardList.set(index,tmp);
    }

    /*
    * 三个人每人轮流抓5张牌
    */


}
